function [ids, vars, names, lons, lats, alts, undefs, JJ] = meta(metafile)

   ## usage:  [ids, vars, names, lons, lats, alts, undefs] = meta (metafile)
   ##
   ## read metadata

   metafile = dos2unix(metafile) ;

   META = {"ids" "vars" "names" "lons" "lats" "alts" "undefs"} ;

   nc = columns(META) ; C = cell(1,nc) ;

   [C{:}] = textread(metafile, "%s %s %s %s %s %s %s", "delimiter", ",") ;

   for j=1:nc
      eval([META{j} " = C{j}(2:end) ;"]) ;
   endfor

   J = cellfun(@(x) isempty(regexp(x, "^#.*")), ids) ;

   j = 0 ;
   for v = sunique(vars)
      JJ{++j} = J(strcmp(vars, v{:})) ;
   endfor

endfunction
